package com.geolab.controller;

import com.geolab.pojo.ResponseResult;
import com.geolab.pojo.clay.*;
import com.geolab.pojo.sand.SandTipResistance;
import com.geolab.service.ResponseResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value = "/clay/extra")
public class ClayExtraDataController {

    @Autowired
    private ResponseResultService resultService;

    @RequestMapping(value = "/queryClayLLById", method = RequestMethod.GET)
    @ResponseBody
    public ResponseResult<List<LL>> selectClayLLById(@RequestParam("ID") Integer ID){
        ResponseResult<List<LL>> result;
        if (ID == null || ID <= 0){
            result = new ResponseResult<>(false,"输入的数据ID有误",null);
        }else {
            result = resultService.queryClayLLById(ID);
            if (!result.isSuccess()){
                System.out.println("按ID查询Clay_LL失败");
            }
            if(result.getData().size() == 0){
                result = new ResponseResult<>(true,"参数正确，但数据库中无该id对应的数据",null);
            }
        }
        return result;
    }

    @RequestMapping(value = "/queryClayLoadById", method = RequestMethod.GET)
    @ResponseBody
    public ResponseResult<List<LoadTestResults>> selectClayLoadById(@RequestParam("ID") Integer ID){
        ResponseResult<List<LoadTestResults>> result;
        if (ID == null || ID <= 0){
            result = new ResponseResult<>(false,"输入的数据ID有误",null);
        }else {
            result = resultService.queryClayLoadByID(ID);
            if (!result.isSuccess()){
                System.out.println("按ID查询Clay_Load失败");
            }
            if(result.getData().size() == 0){
                result = new ResponseResult<>(true,"参数正确，但数据库中无该id对应的数据",null);
            }
        }
        return result;
    }

    @RequestMapping(value = "/queryClayPLById", method = RequestMethod.GET)
    @ResponseBody
    public ResponseResult<List<PL>> selectClayPLById(@RequestParam("ID") Integer ID){
        ResponseResult<List<PL>> result;
        if (ID == null || ID <= 0){
            result = new ResponseResult<>(false,"输入的数据ID有误",null);
        }else {
            result = resultService.queryClayPLByID(ID);
            if (!result.isSuccess()){
                System.out.println("按ID查询Clay_PL失败");
            }
            if(result.getData().size() == 0){
                result = new ResponseResult<>(true,"参数正确，但数据库中无该id对应的数据",null);
            }
        }
        return result;
    }

    @RequestMapping(value = "/queryClayDetailById", method = RequestMethod.GET)
    @ResponseBody
    public ResponseResult<SoilDetail> selectClayDetailById(@RequestParam("ID") Integer ID){
        ResponseResult<SoilDetail> result;
        if (ID == null || ID <= 0){
            result = new ResponseResult<>(false,"输入的数据ID有误",null);
        }else {
            result = resultService.queryClayDetailByID(ID);
            if (!result.isSuccess()){
                System.out.println("按ID查询Clay_Detail失败");
            }
        }
        return result;
    }

    @RequestMapping(value = "/queryClaySuById", method = RequestMethod.GET)
    @ResponseBody
    public ResponseResult<List<Su>> selectClaySuById(@RequestParam("ID") Integer ID){
        ResponseResult<List<Su>> result;
        if (ID == null || ID <= 0){
            result = new ResponseResult<>(false,"输入的数据ID有误",null);
        }else {
            result = resultService.queryClaySuByID(ID);
            if (!result.isSuccess()){
                System.out.println("按ID查询Clay_Su失败");
            }
            if(result.getData().size() == 0){
                result = new ResponseResult<>(true,"参数正确，但数据库中无该id对应的数据",null);
            }
        }
        return result;
    }

    @RequestMapping(value = "/queryClayQcById", method = RequestMethod.GET)
    @ResponseBody
    public ResponseResult<List<TipResistance>> selectClayQcById(@RequestParam("ID") Integer ID){
        ResponseResult<List<TipResistance>> result;
        if (ID == null || ID <= 0){
            result = new ResponseResult<>(false,"输入的数据ID有误",null);
        }else {
            result = resultService.queryClayQcByID(ID);
            if (!result.isSuccess()){
                System.out.println("按ID查询Clay_Qc失败");
            }
            if(result.getData().size() == 0){
                result = new ResponseResult<>(true,"参数正确，但数据库中无该id对应的数据",null);
            }
        }
        return result;
    }

    @RequestMapping(value = "/queryClayWaterById", method = RequestMethod.GET)
    @ResponseBody
    public ResponseResult<List<w>> selectClayWaterById(@RequestParam("ID") Integer ID){
        ResponseResult<List<w>> result;
        if (ID == null || ID <= 0){
            result = new ResponseResult<>(false,"输入的数据ID有误",null);
        }else {
            result = resultService.queryClayWaterByID(ID);
            if (!result.isSuccess()){
                System.out.println("按ID查询Clay_Water失败");
            }
            if(result.getData().size() == 0){
                result = new ResponseResult<>(true,"参数正确，但数据库中无该id对应的数据",null);
            }
        }
        return result;
    }

    @RequestMapping(value = "/queryClayWeightById", method = RequestMethod.GET)
    @ResponseBody
    public ResponseResult<List<γ>> selectClayWeightById(@RequestParam("ID") Integer ID){
        ResponseResult<List<γ>> result;
        if (ID == null || ID <= 0){
            result = new ResponseResult<>(false,"输入的数据ID有误",null);
        }else {
            result = resultService.queryClayWeightByID(ID);
            if (!result.isSuccess()){
                System.out.println("按ID查询Clay_Weight失败");
            }
            if(result.getData().size() == 0){
                result = new ResponseResult<>(true,"参数正确，但数据库中无该id对应的数据",null);
            }
        }
        return result;
    }

}
